<template>
  <div id="app">
      <router-view />
    <!-- 根据router中配置的meta用来显示和隐藏底部导航tabbar -->
    <FootBar v-if="$route.meta.TabbarShow" v-bind:show="show"/>
  </div>
</template>
<script>
import FootBar from "./components/FootBar.vue";
var hrt = document.querySelector("body").scrollHeight; //获取当前可视区域的高度存到hrt变量
window.resize = function () {
  //在页面整体加载完毕时
  document.querySelector("#app").style.height = hrt + "px"; //把获取到的高度赋值给根div
};
export default {
  name: "App",
  components: { FootBar },
  data(){
    return{
      show:0,
      wxUserInfo:{},
      isPower:3
    }
  },
  watch:{
    $route(to){
      if(to.path=="/releasepromotion"|| to.path=="/recruitment" || to.path=="/recruitmentdetail" || to.path=="/recruitmentdetails" || to.path=="details"){
        if(this.isPower==3){
          return;
        }else{
          this.show=1
        }
      }else if(to.path=="/atricle" ||to.path=="/publishArticle" || to.path=="/previewArticle" || to.path=="/sharedetail"){
        if(this.isPower==3){
          return;
        }else{
          this.show=2
        }
      }else if(to.path=="/post" || to.path=="/publishPost" || to.path=="/postDetail" || to.path=="/postShareDetail"){
        if(this.isPower==3){
          return;
        }else{
          this.show=3
        }
      }else if(to.path=="/video" || to.path=="/publishVideo" || to.path=="/videoDetail" || to.path=="/videoShareDetail"){
        if(this.isPower==3){
          return;
        }else{
          this.show=4
        }
      }else{
        this.show=0
      }
    }
  },
  mounted(){
    this.isCustomer()
  },
  methods:{
    //判断是否有权限创建
    async isCustomer () {
      this.wxUserInfo = JSON.parse(sessionStorage.getItem("userWxData"));
      let account = sessionStorage.getItem("agentId");
      let res = await this.$api.isCustomer({
        openId: this.wxUserInfo.openid,
        account,
        id: this.$store.state.userInfo.id,
        phone: this.$store.state.userInfo.phone,
      });
      this.isPower = res.data;
    },
  }
};
</script>

<style lang="less">
</style>
